package com.example.finalproject.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.finalproject.fragment.AccountFragment;
import com.example.finalproject.fragment.WallpaperFragment;
import com.example.finalproject.fragment.WeatherFragment;

public class ViewPagerAdapter extends FragmentStateAdapter {
    private final WeatherFragment weatherFragment = new WeatherFragment();
    private final WallpaperFragment wallpaperFragment = new WallpaperFragment();
    private final AccountFragment accountFragment = new AccountFragment();
    public ViewPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
        super(fragmentActivity);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        switch (position) {
            case 0:
                return weatherFragment;
            case 1:
                return wallpaperFragment;
            case 2:
                return accountFragment;
        }
        return weatherFragment;
    }

    @Override
    public int getItemCount() {
        return 3;
    }

    public String getItemTitle(final int position) {
        switch (position) {
            case 0:
                return "天气";
            case 1:
                return "壁纸";
            case 2:
                return "我的";
        }
        return "";
    }
}
